package com.ev.hr.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.ev.hr.dao.BeforeExperienceDao;
import com.ev.hr.domain.BeforeExperienceDO;
import com.ev.hr.service.BeforeExperienceService;
import com.ev.hr.vo.BeforeExperiencePageParam;
import com.ev.framework.utils.R;
import com.ev.apis.model.DsResultResponse;
import com.google.common.collect.Maps;


@Service
public class BeforeExperienceServiceImpl implements BeforeExperienceService {
	@Autowired
	private BeforeExperienceDao beforeExperienceDao;
	
	@Override
	public BeforeExperienceDO get(Long id){
		return beforeExperienceDao.get(id);
	}
	
	@Override
	public List<BeforeExperienceDO> list(Map<String, Object> map){
		return beforeExperienceDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return beforeExperienceDao.count(map);
	}
	
	@Override
	public int save(BeforeExperienceDO beforeExperience){
		return beforeExperienceDao.save(beforeExperience);
	}
	
	@Override
	public int update(BeforeExperienceDO beforeExperience){
		return beforeExperienceDao.update(beforeExperience);
	}

	@Override
	public int updateAll(BeforeExperienceDO beforeExperience){
		return beforeExperienceDao.updateAll(beforeExperience);
	}
	
	@Override
	public int remove(Long id){
		return beforeExperienceDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return beforeExperienceDao.batchRemove(ids);
	}

	@Override
	public R saveAndVerify(BeforeExperienceDO saveParam){
		if(saveParam.getId()!=null){
			return beforeExperienceDao.update(saveParam)>0?R.ok():R.error();
		}
		return beforeExperienceDao.save(saveParam)>0?R.ok():R.error();
	}

	@Override
	public Map<String, Object> getById(Long id) {
		BeforeExperienceDO beforeExperience = beforeExperienceDao.get(id);
		if (beforeExperience != null) {
			Map<String,Object> result = Maps.newHashMap();
			result.put("data",beforeExperience);
			return R.ok(result);
		}
		return R.error();
	}

	@Override
	public Map<String, Object> pageList(BeforeExperiencePageParam pageParam) {
		Map<String,Object> result = Maps.newHashMap();
		List<Map<String, Object>> data = beforeExperienceDao.pageList(pageParam);
		int total = beforeExperienceDao.pageCount(pageParam);
		result.put("data", new DsResultResponse(pageParam.getPageno(),pageParam.getPagesize(),total,data));
		return R.ok(result);
	}

}
